#include "baseform.h"
#include "ui_baseform.h"
#include "config/constants.h"


BaseForm::BaseForm(QMainWindow *parent) :
    QMainWindow(parent),
    ui(new Ui::BaseForm)
{
    ui->setupUi(this);
    this->setWindowModality(Qt::ApplicationModal);
    setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
    addTools();
}

BaseForm::~BaseForm()
{
    delete returnAction;
    delete dataMgrAction;
    delete printAction;
    delete mymenu;

    mymenu = nullptr;

    delete ui;

}

void BaseForm::setCallback(std::function<void (const QString &)> _callback)
{

    this->callback = _callback;
    LOG_INFO << "tcp send thread id = " << QThread::currentThread();

}

void BaseForm::setCallback2000(std::function<void (const QString &)> _callback)
{
    this->callback2000 = _callback;
    LOG_INFO << "tcp send thread id = " << QThread::currentThread();
}

void BaseForm::addTools()
{
    mymenu = this->addToolBar("返回");

    returnAction      = new QAction(tr("返回"), this);
    dataMgrAction  = new QAction(tr("数据管理"), this);

    printAction   = new QAction(tr("打印"), this);

    mymenu->addAction(returnAction);
    mymenu->addAction(dataMgrAction);
    mymenu->addAction(printAction);
}
